home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / tcsh / dist / ed.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-21  |  8.5 KB  |  238 lines

  1. /* $Header: /home/hyperion/mu/christos/src/sys/tcsh-6.01/RCS/ed.h,v 3.12 1991/12/19 22:34:14 christos Exp $ */
  2. /*
  3.  * ed.h: Editor declarations and globals
  4.  */
  5. /*-
  6.  * Copyright (c) 1980, 1991 The Regents of the University of California.
  7.  * All rights reserved.
  8.  *
  9.  * Redistribution and use in source and binary forms, with or without
  10.  * modification, are permitted provided that the following conditions
  11.  * are met:
  12.  * 1. Redistributions of source code must retain the above copyright
  13.  *    notice, this list of conditions and the following disclaimer.
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in the
  16.  *    documentation and/or other materials provided with the distribution.
  17.  * 3. All advertising materials mentioning features or use of this software
  18.  *    must display the following acknowledgement:
  19.  *    This product includes software developed by the University of
  20.  *    California, Berkeley and its contributors.
  21.  * 4. Neither the name of the University nor the names of its contributors
  22.  *    may be used to endorse or promote products derived from this software
  23.  *    without specific prior written permission.
  24.  *
  25.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  26.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  29.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  31.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  32.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  33.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  34.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  35.  * SUCH DAMAGE.
  36.  */
  37. #ifndef _h_ed
  38. #define _h_ed
  39.  
  40. #ifndef EXTERN
  41. # define EXTERN extern
  42. #endif
  43.  
  44. #define TABSIZE        8    /* usually 8 spaces/tab */
  45. #define MAXMACROLEVELS    10    /* max number of nested kbd macros */
  46.  
  47. extern int errno;
  48.  
  49. /****************************************************************************/
  50. /* stuff for the different states returned by the character editor routines */
  51. /****************************************************************************/
  52.  
  53. #define CCRETVAL    char    /* size needed for the different char editor */
  54.  /* return values */
  55.  
  56. #define KEYCMD   unsigned char    /* size needed to index into CcFuncTbl */
  57.  /* Must be unsigned                */
  58.  
  59. typedef CCRETVAL(*PFCmd) __P((int));    /* pointer to function returning CCRETVAL */
  60.  
  61. struct KeyFuncs {        /* for the "bind" shell command */
  62.     char   *name;        /* function name for bind command */
  63.     int     func;        /* function numeric value */
  64.     char   *description;    /* description of function */
  65. };
  66.  
  67. extern PFCmd CcFuncTbl[];    /* table of available commands */
  68. extern KEYCMD CcKeyMap[];    /* keymap table, each index into above tbl */
  69. extern KEYCMD CcAltMap[];    /* Alt keymap table */
  70. extern KEYCMD CcEmacsMap[];    /* keymap table for Emacs default bindings */
  71. extern KEYCMD CcViMap[];    /* keymap table for Vi input mode defaults */
  72. extern KEYCMD CcViCmdMap[];    /* for Vi command mode defaults */
  73. extern struct KeyFuncs FuncNames[];    /* string names vs. CcFuncTbl indices */
  74.  
  75. extern KEYCMD NumFuns;        /* number of KEYCMDs in above table */
  76.  
  77. #define    CC_ERROR        100    /* there should NOT be 100 different... */
  78. #define CC_FATAL        101    /* fatal error: inconsistant, must
  79.                      * reset */
  80. #define    CC_NORM            0
  81. #define    CC_NEWLINE        1
  82. #define    CC_EOF            2
  83. #define    CC_COMPLETE        3
  84. #define    CC_LIST_CHOICES        4
  85. #define    CC_LIST_GLOB        5
  86. #define CC_EXPAND_GLOB        6
  87. #define    CC_HELPME        9
  88. #define CC_CORRECT        10
  89. #define CC_WHICH        11
  90. #define CC_ARGHACK        12
  91. #define CC_CORRECT_L        13
  92. #define CC_REFRESH        14
  93. #define CC_EXPAND_VARS        15
  94. #define CC_NORMALIZE_PATH    16
  95.  
  96. typedef union Xmapval {        /* value passed to the Xkey routines */
  97.     KEYCMD cmd;
  98.     Char *str;
  99. } XmapVal;
  100.  
  101. #define XK_NOD    -1        /* Internal tree node */
  102. #define XK_CMD     0        /* X-key was an editor command */
  103. #define XK_STR     1        /* X-key was a string macro */
  104. #define XK_EXE     2        /* X-key was a unix command */
  105.  
  106. /****************************/
  107. /* Editor state and buffers */
  108. /****************************/
  109.  
  110. EXTERN KEYCMD *CurrentKeyMap;    /* current command key map */
  111. EXTERN int inputmode;        /* insert, replace, replace1 mode */
  112. EXTERN Char GettingInput;    /* true if getting an input line (mostly) */
  113. EXTERN Char NeedsRedraw;    /* for editor and twenex error messages */
  114. EXTERN Char InputBuf[INBUFSIZE];    /* the real input data */
  115. EXTERN Char *LastChar, *Cursor;    /* point to the next open space */
  116. EXTERN Char *InputLim;        /* limit of size of InputBuf */
  117. EXTERN Char MetaNext;        /* flags for ^V and ^[ functions */
  118. EXTERN Char AltKeyMap;        /* Using alternative command map (for vi mode) */
  119. EXTERN Char VImode;        /* true if running in vi mode (PWP 6-27-88) */
  120. EXTERN Char *Mark;        /* the emacs "mark" (dot is Cursor) */
  121. EXTERN Char DoingArg;        /* true if we have an argument */
  122. EXTERN int Argument;        /* "universal" argument value */
  123. EXTERN KEYCMD LastCmd;        /* previous command executed */
  124. EXTERN Char KillBuf[INBUFSIZE];    /* kill buffer */
  125. EXTERN Char *LastKill;        /* points to end of kill buffer */
  126.  
  127. EXTERN Char UndoBuf[INBUFSIZE];
  128. EXTERN Char *UndoPtr;
  129. EXTERN int  UndoSize;
  130. EXTERN int  UndoAction;
  131.  
  132. EXTERN Char HistBuf[INBUFSIZE];    /* history buffer */
  133. EXTERN Char *LastHist;        /* points to end of history buffer */
  134. EXTERN int Hist_num;        /* what point up the history we are at now. */
  135. EXTERN Char WhichBuf[INBUFSIZE];    /* buffer for which command */
  136. EXTERN Char *LastWhich;        /* points to end of which buffer */
  137. EXTERN Char *CursWhich;        /* points to the cursor point in which buf */
  138. EXTERN int HistWhich;        /* Hist_num is saved in this */
  139. EXTERN Char *SearchPrompt;    /* points to string that holds search prompt */
  140. EXTERN Char DoingSearch;    /* true if we are doing a history search */
  141. EXTERN char Expand;        /* true if we are expanding a line */
  142. EXTERN Char HistLit;        /* true if history lines are shown literal */
  143. EXTERN Char CurrentHistLit;    /* Literal status of current show history line */
  144.  
  145. /*
  146.  * These are truly extern
  147.  */
  148. extern Char PromptBuf[];
  149. extern int MacroLvl;
  150.  
  151. EXTERN Char *KeyMacro[MAXMACROLEVELS];
  152.  
  153. EXTERN Char **Display;        /* display buffer seed vector */
  154. EXTERN int CursorV,        /* real cursor vertical (line) */
  155.         CursorH,        /* real cursor horisontal (column) */
  156.         TermV,            /* number of real screen lines
  157.                  * (sizeof(DisplayBuf) / width */
  158.         TermH;            /* screen width */
  159. EXTERN Char **Vdisplay;        /* new buffer */
  160.  
  161. /* Variables that describe terminal ability */
  162. EXTERN int T_Lines, T_Cols;    /* Rows and Cols of the terminal */
  163. EXTERN Char T_CanIns;        /* true if I can insert characters */
  164. EXTERN Char T_CanDel;        /* dito for delete characters */
  165. EXTERN Char T_Tabs;        /* true if tty interface is passing tabs */
  166. EXTERN speed_t T_Speed;        /* Tty input Baud rate */
  167. EXTERN Char T_CanCEOL;        /* true if we can clear to end of line */
  168. EXTERN Char T_CanUP;        /* true if this term can do reverse linefeen */
  169. EXTERN Char T_HasMeta;        /* true if we have a meta key */
  170.  
  171. /* note the extra characters in the Strchr() call in this macro */
  172. #define isword(c)    (Isalpha(c)||Isdigit(c)||Strchr(word_chars,c))
  173. #define min(x,y)    (((x)<(y))?(x):(y))
  174. #define max(x,y)    (((x)>(y))?(x):(y))
  175.  
  176. /*
  177.  * Terminal dependend data structures
  178.  */
  179. typedef struct {
  180. #if defined(POSIX) || defined(TERMIO)
  181. # ifdef POSIX
  182.     struct termios d_t;
  183. # else
  184.     struct termio d_t;
  185. # endif /* POSIX */
  186. #else /* SGTTY */
  187. # ifdef TIOCGETP
  188.     struct sgttyb d_t;
  189. # endif /* TIOCGETP */
  190. # ifdef TIOCGETC
  191.     struct tchars d_tc;
  192. # endif /* TIOCGETC */
  193. # ifdef TIOCGPAGE
  194.     struct ttypagestat d_pc;
  195. # endif /* TIOCGPAGE */
  196. # ifdef TIOCLGET
  197.     int d_lb;
  198. # endif /* TIOCLGET */
  199. #endif /* POSIX || TERMIO */
  200. #ifdef TIOCGLTC
  201.     struct ltchars d_ltc;
  202. #endif /* TIOCGLTC */
  203. } ttydata_t;
  204.  
  205. #define MODE_INSERT    0
  206. #define MODE_REPLACE    1
  207. #define MODE_REPLACE_1    2
  208.  
  209. #define EX_IO    0    /* while we are executing    */
  210. #define ED_IO    1    /* while we are editing        */
  211. #define TS_IO    2    /* new mode from terminal    */
  212. #define QU_IO    2    /* used only for quoted chars    */
  213. #define NN_IO    3    /* The number of entries    */
  214.  
  215. #if defined(POSIX) || defined(TERMIO)
  216. # define M_INPUT    0
  217. # define M_OUTPUT    1
  218. # define M_CONTROL    2
  219. # define M_LINED    3
  220. # define M_CHAR        4
  221. # define M_NN        5
  222. #else /* GSTTY */
  223. # define M_CONTROL    0
  224. # define M_LOCAL    1
  225. # define M_CHAR        2
  226. # define M_NN        3
  227. #endif /* TERMIO */
  228. typedef struct { 
  229.     char *t_name;
  230.     int  t_setmask;
  231.     int  t_clrmask;
  232. } ttyperm_t[NN_IO][M_NN];
  233.  
  234. extern ttyperm_t ttylist;
  235. #include "ed.decls.h"
  236.  
  237. #endif /* _h_ed */
  238.